package com.xiaoyi.picshow;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 通过重写  onInterceptTouchEvent  , 返回 false 。
 * 解决 viewpager 和 photoview 滑动冲突的问题 。<br>
 */
public class BigPhotoViewPager extends MyViewPager {

//    private boolean isLocked;
    public BigPhotoViewPager(Context context) {
        super(context);
//        isLocked = false;
    }

    public BigPhotoViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
//        isLocked = false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return false;
        }
//        if (!isLocked) {
//            try {
//                return super.onInterceptTouchEvent(ev);
//            } catch (IllegalArgumentException e) {
//                e.printStackTrace();
//                return false;
//            }
//        }
//        return false;
    }



/*    private float  mLastMotionX;
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        final int action = event.getAction();
        final float x = event.getX();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                mLastMotionX = x;
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:

                if (Math.abs(x - mLastMotionX) < 100) {
                    return true;
                }
                break;
            default:
                break;
        }
        return super.onTouchEvent(event);
    }*/



}
